package cli.menu;

/**
 * BudgetBuoy
 * 
 * Simplify your personal expense management
 * 
 * @team cs2103jan13-w15-3j
 */

//--------------------------------------------------------------

/**
 * ManageCategories Class
 * 
 * Description: 
 * 
 * 
 * @package   cli.menu
 * @author    Lai Yong Quan (A0080909Y)
 * @editor(s) -
 */


class ManageCategories extends Function{
	
	private static final String[] MANAGECAT = {
		
	 "-= Main menu > Manage Categories =-",
	 "[b]: back [u]: undo [r]: redo [h]: home menu",
	 "1. Add Category",
	 "2. Rename a Category",
	 "3. Merge Categories",
	 "4. Delete a Category",
	 "",
	"Option: "
};

	private static final State CURRENT = State.MANAGECATEGORIES;
	private static final State BACK = State.MAINMENU;
	
	public static State runMenu(){
		String input = null;
		while(input == null || input.length() == 0){
		cli.print(MANAGECAT);
		input = cli.nextLine();
		}
		cli.clearScreen();
		
		return processInput(input);
	}
	
	private static State processInput(String input){
		
		if(input.length() != 1)
			return CURRENT;
		State nextState = CURRENT;
		char charInput = input.charAt(0);
		switch (charInput) {
		case 'b':
		case 'B':
			nextState = BACK;
		case 'H':
		case 'h':
			nextState = State.MAINMENU;
			break;
		case 'u':
		case 'U':
			tools.undo();
			break;
		case 'r':
		case 'R':
			tools.redo();
			break;
		case '1':
			nextState = State.ADDCATEGORY;
			break;
		case '2':
			nextState = State.RENAMECATEGORY;
		break;
		case '3':
			nextState = State.MERGECATEGORIES;
	break;
		case '4':
			nextState = State.DELETECATEGORY;
		break;
		default: {
			cli.println("Unexpected input");
			break;
		}	
	}
		
		return nextState;
		
	}
	
	
}